import { defineStore } from "pinia";

const useUserStore = defineStore("user", {
  state: () => {
    return {
      token: "",
      expireTime: -1,
      baseUrl: "http://101.35.249.138/back",
      userInfo: {},
    };
  },
  getters: {
    isLogin: (state) => {
      return state.token && state.expireTime > Date.now();
    },
  },
  actions: {
    setUserInfo(userInfo: any) {
      this.userInfo = userInfo;
    },
    setToken(token: string) {
      this.token = token;
    },
  },
  persist: true,
});
export default useUserStore;
